package MailLogger;
import java.io.*;
import java.net.*;
import java.util.*;

public class MailLogger {
  MailSender ms;
  String reciever;
  String title;
  public MailLogger(String reciever) {
    String account = "ktsong";
    account = "cyhuang";
    account = "susan";
    this.ms = new MailSender("m-smtp.NCTU.edu.tw", account+"@mail.nctu.eud.tw");
    this.reciever = reciever;
    this.title = "Notification";
  }
  public void log(String msg) throws Exception {
    try {
      ms.sendMail(this.reciever, this.title, msg);    
    }  
    catch(Exception e){
      e.printStackTrace();
      throw new Exception("log failed");
    }
  }
  public void close() throws Exception {
    try{
      ms.close(); 
    }  
    catch(Exception e){
      e.printStackTrace();
      throw new Exception("close failed");
    }
  }
  public static void main(String[] args){
    MailLogger ml = new MailLogger("chintown@gmail.com");
    try {
      ml.log("tttt");
      ml.close();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}
